package com.yijiaw.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllMessages", query = "select myMessage from Message myMessage"),
		@NamedQuery(name = "findMessageByCompany", query = "select myMessage from Message myMessage where myMessage.company = ?1"),
		@NamedQuery(name = "findMessageByCompanyContaining", query = "select myMessage from Message myMessage where myMessage.company like ?1"),
		@NamedQuery(name = "findMessageByContent", query = "select myMessage from Message myMessage where myMessage.content = ?1"),
		@NamedQuery(name = "findMessageByDate", query = "select myMessage from Message myMessage where myMessage.date = ?1"),
		@NamedQuery(name = "findMessageById", query = "select myMessage from Message myMessage where myMessage.id = ?1"),
		@NamedQuery(name = "findMessageByName", query = "select myMessage from Message myMessage where myMessage.name = ?1"),
		@NamedQuery(name = "findMessageByNameContaining", query = "select myMessage from Message myMessage where myMessage.name like ?1"),
		@NamedQuery(name = "findMessageByPhone", query = "select myMessage from Message myMessage where myMessage.phone = ?1"),
		@NamedQuery(name = "findMessageByPhoneContaining", query = "select myMessage from Message myMessage where myMessage.phone like ?1"),
		@NamedQuery(name = "findMessageByPrimaryKey", query = "select myMessage from Message myMessage where myMessage.id = ?1") })
@Table(catalog = "yijiaw", name = "message")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "temp/com/yijiaw/domain", name = "Message")
public class Message implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "name", length = 30)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;
	/**
	 */

	@Column(name = "company", length = 100)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String company;
	/**
	 */

	@Column(name = "phone", length = 40)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String phone;
	/**
	 */

	@Column(name = "content", columnDefinition = "TEXT")
	@Basic(fetch = FetchType.EAGER)
	@Lob
	@XmlElement
	String content;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Calendar date;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public void setCompany(String company) {
		this.company = company;
	}

	/**
	 */
	public String getCompany() {
		return this.company;
	}

	/**
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 */
	public String getPhone() {
		return this.phone;
	}

	/**
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 */
	public String getContent() {
		return this.content;
	}

	/**
	 */
	public void setDate(Calendar date) {
		this.date = date;
	}

	/**
	 */
	public Calendar getDate() {
		return this.date;
	}

	/**
	 */
	public Message() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Message that) {
		setId(that.getId());
		setName(that.getName());
		setCompany(that.getCompany());
		setPhone(that.getPhone());
		setContent(that.getContent());
		setDate(that.getDate());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("company=[").append(company).append("] ");
		buffer.append("phone=[").append(phone).append("] ");
		buffer.append("content=[").append(content).append("] ");
		buffer.append("date=[").append(date).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Message))
			return false;
		Message equalCheck = (Message) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
